import java.util.Scanner;

public class Anagram {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        char[] firstPhrase;
        char[] secondPhrase;

        System.out.println("Enter phrases to check:");
        firstPhrase = getStripPhraseCharacters(in);
        secondPhrase = getStripPhraseCharacters(in);
        if (isAnagram(firstPhrase, secondPhrase)) {
            System.out.println("yeah, it is");
        } else {
            System.out.println("no, it isn't");
        }
        in.close();
    }

    private static boolean isAnagram(char[] firstPhrase, char[] secondPhrase) {
        if (firstPhrase.length != secondPhrase.length) {
            return false;
        }
        for (int i = 0; i < firstPhrase.length; i++) {
            boolean charPresentInBothPhrases = false;

            for (int j = i; j < secondPhrase.length; j++) {
                if (firstPhrase[i] == secondPhrase[j]) {
                    switchCharacters(secondPhrase, i, j);
                    charPresentInBothPhrases = true;
                    break;
                }
            }
            if (!charPresentInBothPhrases) {
                return false;
            }
        }
        return true;
    }

    private static char[] getStripPhraseCharacters(Scanner in) {
        return in.nextLine().toLowerCase().replaceAll("[ \t]", "").toCharArray();
    }

    private static void switchCharacters(char[] phrase, int firstIndex, int secondIndex) {
        char buffer = phrase[secondIndex];

        phrase[secondIndex] = phrase[firstIndex];
        phrase[firstIndex] = buffer;
    }
}